{literal}
<script type="text/javascript" language="javascript">
var urlEditar = '{/literal}{$_site.url}{$urlEditar}{literal}';
var urlApagar = '{/literal}{$_site.url}{$urlApagar}{literal}';
function irPara(pag)
{
	document.form_busca.pag.value = pag;
	jqAjaxForm(document.form_busca, "div_tabela");
}
function anterior()
{
	irPara(parseInt(document.form_busca.pag.value)-1);
}
function proximo()
{
	irPara(parseInt(document.form_busca.pag.value)+1);
}
function editar(codigo)
{
	document.form_acao.action = urlEditar;
	document.form_acao.codigo.value = codigo;
	document.form_acao.acao.value = "editar";
	jqAjaxForm(document.form_acao, "div_form");
}
function excluir(codigo)
{
	document.form_acao.action = urlApagar;
	document.form_acao.codigo.value = codigo;
	document.form_acao.acao.value = "apagar";
	jqAjaxForm(document.form_acao, "div_form");
}


//POPULA MES EXERCICIO
populaSelect("mes_inicio", "{/literal}{$_site.url}{literal}", "gerar-extrato/select-mes-geracao-extrato?cod={/literal}{$mes_inicio}{literal}");

//POPULA ANO EXERCICIO
populaSelect("ano_inicio", "{/literal}{$_site.url}{literal}", "gerar-extrato/select-ano-geracao-extrato?cod={/literal}{$ano_inicio}{literal}");

//POPULA MES EXERCICIO
populaSelect("mes_fim", "{/literal}{$_site.url}{literal}", "gerar-extrato/select-mes-geracao-extrato?cod={/literal}{$mes_fim}{literal}");

//POPULA ANO EXERCICIO
populaSelect("ano_fim", "{/literal}{$_site.url}{literal}", "gerar-extrato/select-ano-geracao-extrato?cod={/literal}{$ano_fim}{literal}");

</script>
{/literal}
	<form name="form_acao" id="form_acao" action="#" method="post">
		<input type="hidden" name="codigo" id="codigo" value=""/>
		<input type="hidden" name="acao" id="acao" value=""/>
	</form>
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="2" class="alpha">
      <tr>
        <td colspan="6" class="mvTituloFundo">Extratos</td>
      </tr>
      <tr>
        <td colspan="6" align="center">
	        <form name="form_busca" id="form_busca" action="{$_site.url}gerar-extrato/tabela" method="post" onsubmit="irPara(document.form_busca.pag.value); return false;">
	        	<table width="100%">
	        		<tr>
	        			<td class="fundoTituloForm bordaFormResp" width="15%">Num. contrato</td>
	        			<td class="bordaFormResp" width="15%"><input type="text" size="3" name="contrato" id=contrato" value="{$contrato}" class="formulario"/></td>
	        			<td class="fundoTituloForm bordaFormResp" width="15%">Nome Cliente</td>
	        			<td class="bordaFormResp" width="55%" colspan="3"><input type="text" name="nome" id=nome" value="{$nome}" class="formulario tamanhoForm"/></td>
	        		</tr>
	 				<tr>
	        			<td class="fundoTituloForm bordaFormResp" width="15%">Num. extrato</td>
                 		<td valign="top" class="bordaFormResp"><input type="text" name="busca" id=busca" value="{$busca}" class="formulario"/></td>
	        			<td class="fundoTituloForm bordaFormResp" width="15%">Per&iacute;odo </td>
                 		<td valign="top" class="bordaFormResp">
							de <select name='mes_inicio' id='mes_inicio' class="formulario"></select> &nbsp;&nbsp;<select name="ano_inicio" id="ano_inicio" class="formulario"></select>
							&agrave; <select name='mes_fim' id='mes_fim' class="formulario"></select> &nbsp;&nbsp;<select name="ano_fim" id="ano_fim" class="formulario"></select>
						</td>
					</tr>
	 				<tr>
                 		<td valign="top" class="bordaFormResp" colspan="6" align="center"><input type="submit" value="Buscar" class="botao"/></td>
					</tr>
	        	</table>
	        	
				<input type="hidden" name="pag" id="pag" value="{$pag}"/>
			</form>
		</td>
      </tr>
      <tr>
        <td colspan="6" align="center"><b>{$total}</b> encontrados, exibindo de <b>{$inicio}</b> a <b>{$fim}</b></td>
      </tr>
      <tr>
        <td valign="top" width="24%" class="paddingTotal3 bgCarla bold">N&uacute;mero</td>
        <td valign="top" width="24%" class="paddingTotal3 bgCarla bold">Cliente</td>
        <td valign="top" width="24%" class="paddingTotal3 bgCarla bold">M&ecirc;s/Ano</td>
        <td valign="top" width="24%" class="paddingTotal3 bgCarla bold">Extrato</td>
        <!-- <td colspan="2" width="4%" align="center" valign="top" class="paddingTotal3 bgCarla bold">A&ccedil;&atilde;o</td> -->
      </tr>
      {foreach name=lista from=$extratos item=extrato}
      <tr>
        <td valign="top" class="fundoTituloForm">{$extrato->vhr_numextrato}</td>
        <td valign="top" class="fundoTituloForm">({$extrato->contrato_id}) {$extrato->vhr_nomepessoa}</td>
        <td valign="top" class="fundoTituloForm">{$extrato->vhr_ano_mes_referencia|substr:4:2|recuperarMesGeracaoExtrato} / {$extrato->vhr_ano_mes_referencia|substr:0:4}</td>
        <td valign="top" class="fundoTituloForm"><a href="{$cteUrlArquivosContrato}{$extrato->contrato_id}/{$ctePathArquivosExtratosContrato}{$extrato->vhr_nomearquivo}" target="_blank"><span class='msgNaoLida'>{$extrato->vhr_nomearquivo}</span></a></td>
        <!-- <td align="center" valign="top" class="fundoTituloForm"><a href="#" onclick="editar('{$extrato->id}'); return false;"><img src="{$_site.url}public/images/ic-cadastrar.gif" alt="Alterar" border="0" title="Alterar"/></a></td>
        <td align="center" valign="top" class="fundoTituloForm"><a href="#" onclick="excluir('{$extrato->id}'); return false;"><img src="{$_site.url}public/images/ic-excluir.gif" alt="Excluir" border="0" title="Excluir"/></a></td> -->
      </tr>
      {/foreach}
      <tr>
        <td colspan="4" align="center">{if $pag gt 1}
		<a href="#" onclick="irPara('1'); return false;"><<</a> 
		<a href="#" onclick="anterior(); return false;"><</a> 
	{else}
		<<  < 
	{/if}
	{section name=foo start=1 loop=$totalPag+1}
		{if $smarty.section.foo.index eq $pag}
			<font color="red">{$smarty.section.foo.index}</font>
		{else}
			<a href="#" onclick="irPara('{$smarty.section.foo.index}'); return false;">{$smarty.section.foo.index}</a>
		{/if}
		{if $smarty.section.foo.index lt $totalPag}
		|
		{/if}
	{/section}
	{if $pag lt $totalPag}
	<a href="#" onclick="proximo(); return false;">></a> 
	<a href="#" onclick="irPara('{$totalPag}'); return false;">>></a>
	{else}
	>  >>
	{/if}</td>
      </tr>
    </table>
